package global

import (
	etcdclient "go.etcd.io/etcd/client/v3"
	"log"
)

var (
	client *etcdclient.Client
)

func InitEtcd() error {
	var err error
	client, err = etcdclient.New(etcdclient.Config{
		Endpoints: []string{
			Config.GetString("etcd.endpoint"),
			//"52.221.194.38:9001",
			//"52.221.194.38:2379",
			//"52.221.194.38:2379",
			//"52.221.194.38:2379",
		},
	})
	if err != nil {
		log.Fatalf("init etcd cli is error: %+v \n", err)
	}
	return nil
}

func GetEtcdCli() *etcdclient.Client {
	return client
}
